<extend name="Public/base" />

<block name="style">
	<style>
		.dragsort {
		    width:400px;
		}
	</style>
</block>

<block name="body">
	<!-- 标题栏 -->
	<div class="main-title cf">
		<h2><present name="data">编辑<else />新增</present>钩子</h2>
	</div>

	<!-- 修改密码表单 -->
	<form action="{:U('updateHook')}" method="post" class="form-horizontal">
        <div class="with-padding">
            <div class="form-item cf">
                <label class="item-label">钩子名称<span class="check-tips">（需要在程序中先添加钩子，否则无效）</span></label>
                <div class="controls">
                    <input type="text" value="{$data.name}" name="name" class="text form-control" style="width: 400px">
                </div>
            </div>
            <div class="form-item cf">
                <label class="item-label">钩子描述<span class="check-tips">（钩子的描述信息）</span></label>
                <div class="controls">
                    <label class="textarea input-large"><textarea name="description" class="form-control" style="width: 400px" >{$data.description}</textarea></label>
                </div>
            </div>
            <div class="form-item cf">
                <label class="item-label">钩子类型<span class="check-tips">（区分钩子的主要用途）</span></label>
                <div class="controls">
                    <select name="type" class="form-control" style="width: auto">
                        <volist name=":C('HOOKS_TYPE')" id="vo">
                            <option value="{$key}" <eq name="data.type" value="$key"> selected</eq>>{$vo}</option>
                        </volist>
                    </select>
                </div>
            </div>
            <present name="data">
                <div class="form-item cf">
                    <label class="item-label">钩子挂载的插件排序<span class="check-tips">（拖动后保存顺序，影响同一个钩子挂载的插件执行先后顺序）</span></label>
                    <div id="drag-container" class="controls" style="position:relative;">
                        <input type="hidden" name="addons" value="{$data.addons}" style="width: 100%" readonly>
                        <script>
                            $(function(){
                                function updateVal() {
                                    var sortVal = [];
                                    $('#hook_sort .kanban-item').each(function(){
                                        if(typeof $(this).data('id') != 'undefined'){
                                            sortVal.push($(this).data('id'));
                                        }

                                    });
                                    $("input[name='addons']").val(sortVal.join(','));

                                }
                                $('#hook_sort').kanbans({'drop':updateVal});
                            })
                        </script>
                        <empty name="data.addons">
                            暂无插件，无法排序
                            <else />
                            <div id="hook_sort" class="kanbans">
                                <div class="kanban panel" data-id="addons">
                                    <div class="panel-heading">
                                        <strong>插件排序</strong>
                                    </div>
                                    <div class="panel-body">
                                        <div class="kanban-list">
                                            <volist name=":explode(',',$data['addons'])" id="addons_vo">
                                                <div class="kanban-item" data-id="{$addons_vo}">
                                                    {$addons_vo}
                                                </div>
                                            </volist>
                                        </div>
                                    </div>
                                </div>
                            </div>

                        </empty>
                    </div>
                </div>
            </present>
        </div>

        <div class="with-padding">
            <input type="hidden" name="id" value="{$data.id}">
            <button type="submit" class="btn submit-btn ajax-post" target-form="form-horizontal">确 定</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>

	</form>

</div>
</block>

<block name="script">
	<present name="data">
	</present>
	<script type="text/javascript">
		$(function(){
			//导航高亮
			highlight_subnav('{:U('Addons/hooks')}');
		})
	</script>
</block>